package com.huang.foundation.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huang.foundation.dao.ZoningCodeDao;
import com.huang.foundation.entity.em.ZoningCodeType;
import com.huang.foundation.entity.po.ZoningCodePO;
import com.huang.foundation.service.ZoningCodeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 行政区划表(ZoningCode)表服务实现类
 *
 * @author HuangShen
 * @since 2021-10-16 23:27:45
 */
@Service("zoningCodeService")
public class ZoningCodeServiceImpl extends ServiceImpl<ZoningCodeDao, ZoningCodePO> implements ZoningCodeService {

    /**
     * 服务对象
     */
    @Resource
    private ZoningCodeDao zoningCodeDao;


    /**
     * 获取区划信息
     *
     * @param zoningCodeType 区划等级
     * @param parentId       父级id
     * @return List<ZoningCodePO>
     */
    @Override
    public List<ZoningCodePO> getZonings(ZoningCodeType zoningCodeType, Long parentId) {

        QueryWrapper<ZoningCodePO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", parentId)
                .eq("dict_code", zoningCodeType.getCode())
                .select("name", "parent_id", "value");

        return this.zoningCodeDao.selectList(queryWrapper);

    }
}

